<?php

namespace IMT\UserBundle\Controller;

use IMT\UserBundle\Entity\Group;

use IMT\AccountBundle\Form\AccountFormType;

use IMT\AccountBundle\Entity\Account;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;


class AccountController extends Controller
{
	public function indexAction($id)
	{
		$user = $this->container->get('security.context')->getToken()->getUser();
			
		$account = new Account();
		$account->setActive(true);
		$account->setUser($user);
		 
		$accountType = $this->getDoctrine()
		->getRepository('IMTAccountBundle:AccountType')
		->find(intval($this->container->getParameter('default_account_id')));
		$account->setAccountType($accountType);
		 
		$form = $this->createFormBuilder($account)
		->add('title', 'text')
		->add('color', 'choice', array(
				'choices' => array(
						'fc-event-blue' => 'Bleu',
						'fc-event-green' => 'Vert',
						'fc-event-azul' => 'Bleu clair',
						'fc-event-red' => 'Rouge',
						'fc-event-black' => 'Noir',
						'fc-event-orange' => 'Orange'
				)
		))
		->add('username', 'text', array('required'=> false))
		->add('password', 'password', array('required'=> false))
		->getForm();
		
		return $this->render('IMTUserBundle:Account:list_account.html.twig', array(
				'newAccountForm' => $form->createView(),
				'openAccount' => $id
		));
	}
}
